< previous page page_751 next page >

Page 751
The code sample uses a series of If statements to determine if the current message is unread, has been submitted, and has been sent on or later than July 4, 1998.
tip.gif
Using an interface such as Active Messaging might make your program more error prone because of the uncontrollable user interaction. For this reason, I suggest creating user-defined functions with error handling for each task you want to perform (logging on, sending a message, and so on).

In this section, we have given you a glimpse into the Active Messaging Library. To discover the full list of available properties and methods, use Visual Basic's Object Browser or see the help file ACTMSG.HLP included in the download file.
Using the Internet Transfer Control
Another Internet feature of Visual Basic is the Internet Transfer control. This control allows you to establish a connection to another computer and transfer files. It is Microsoft's attempt to make it easy to use two Internet protocols: HTTP and FTP. HTTP, or Hypertext Transfer Protocol, is the means by which a Web browser communicates with a Web server. If you have transferred information across the Internet, you may already be familiar with the File Transfer Protocol (FTP). In this section, we'll look at a sample use of both protocols.
Retrieving HTML
When you access a Web page normally, the browser uses the GET command (defined by the HTTP protocol) to ask the Web server for a document. For example, if you open the URL http://www.food.com/peanuts.html, the browser establishes a connection with the machine at the address www.food.com and then sends the command GET /peanuts.html. The HTML is returned to the browser over the connection as plain text, and the browser uses its own logic to parse and format it appropriately.
When you use the Internet Transfer control with the HTTP protocol, you can retrieve HTML for processing by your own program. For example, you could periodically query a Web site for stock information. Your VB program could then save the stock information in a SQL database for other users to view. In other words, the Internet Transfer control can be used to automatically collect data from a Web site.
exe.gif As an example, we will use the Internet Transfer control to retrieve HTML and print it on a form. To create the sample project, perform the following steps:
1. Open Visual Basic and create a new Standard EXE project.
2. Display the Project Components dialog box and add a reference to Microsoft Internet Transfer Control 6.0.
3. Draw an instance of the Internet Transfer control on the form. Note that this control will appear as an icon no matter how large you draw it.
4. Add a text box named txtURL and a command button named cmdRetrieve.

 
< previous page page_751 next page >